home *** CD-ROM | disk | FTP | other *** search
- package symantec.itools.db.net;
-
- import java.io.DataInputStream;
- import java.io.DataOutputStream;
- import java.io.IOException;
- import symjava.sql.Date;
- import symjava.sql.SQLException;
- import symjava.sql.Timestamp;
-
- class NetDate extends DateTimeField {
- Date _dateVal;
-
- int getType() {
- return 75;
- }
-
- void readData(DataInputStream is) throws SQLException, IOException, ErrorException {
- int iYear = 0;
- ServerObject obj = (ServerObject)NetClass.getNextObject(is);
- if (obj.getType() == 51) {
- iYear = ((NetData)obj).getInt();
- } else {
- ((ServerObject)this).onObjectError(obj);
- }
-
- int iMonth = 0;
- obj = (ServerObject)NetClass.getNextObject(is);
- if (obj.getType() == 51) {
- iMonth = ((NetData)obj).getInt();
- } else {
- ((ServerObject)this).onObjectError(obj);
- }
-
- int iDay = 0;
- obj = (ServerObject)NetClass.getNextObject(is);
- if (obj.getType() == 51) {
- iDay = ((NetData)obj).getInt();
- } else {
- ((ServerObject)this).onObjectError(obj);
- }
-
- if (!super._null) {
- try {
- this._dateVal = new Date(iYear, iMonth - 1, iDay);
- } catch (IllegalArgumentException var6) {
- this._dateVal = null;
- }
- } else {
- this._dateVal = null;
- }
- }
-
- void writeData(DataOutputStream os) throws IOException {
- NetData data = new NetData((short)this._dateVal.getYear());
- data.write(os);
- data = new NetData((short)(this._dateVal.getMonth() + 1));
- data.write(os);
- data = new NetData((short)this._dateVal.getDate());
- data.write(os);
- }
-
- public String getString() throws SQLException {
- return ((Field)this).isNull() ? null : this._dateVal.toString();
- }
-
- public Date getDate() throws SQLException {
- return ((Field)this).isNull() ? null : this._dateVal;
- }
-
- public Timestamp getTimestamp() throws SQLException {
- return ((Field)this).isNull() ? null : new Timestamp(this._dateVal.getYear(), this._dateVal.getMonth(), this._dateVal.getDate(), 0, 0, 0, 0);
- }
-
- public void setString(String x) throws SQLException {
- this._dateVal = Date.valueOf(x);
- super._null = false;
- }
-
- public void setDate(Date x) throws SQLException {
- this._dateVal = x;
- super._null = false;
- }
-
- public void setTimestamp(Timestamp x) throws SQLException {
- this._dateVal.setYear(((java.util.Date)x).getYear());
- this._dateVal.setMonth(((java.util.Date)x).getMonth());
- this._dateVal.setDate(((java.util.Date)x).getDate());
- super._null = false;
- }
-
- public int getSQLType() {
- return 91;
- }
-
- public Object getObject() throws SQLException {
- return this.getDate();
- }
-
- public void setObject(Object obj) throws SQLException {
- this.setDate((Date)obj);
- }
- }
-